set more off
cd "/Users/cason/Dropbox/Research/Gender_groups/data/data2021"
**cd "C:\Research\Gender_groups\data"

** First what are the beliefs by gender for the Part 2 allocation tasks **
use beliefs_survey.dta

gen FemaleID=1+(-1*survey2)

gen TypeZID = type-1

gen subsess=sessnum+Subject

** Belief variables abbreviation 1M2W means 1 man, 2 women in group, etc. **
gen kindMenOverall = 100 - menMoverall
gen kind3Men = 100 - menM3M 
gen kindMen2M1W = 100 - menM2M1W 
gen kindMen1M2W = 100 - menM1M2W 

gen kindWomenOverall = 100 - womenMoverall 
gen kind3Women = 100 - womenM3W 
gen kindWomen2M1W = 100 - womenM2M1W
gen kindWomen1M2W = 100 - womenM1M2W 

** Mean beliefs for Figure 5 **
sum kindMenOverall kind3Men kindMen2M1W kindMen1M2W kindWomenOverall kind3Women kindWomen2M1W kindWomen1M2W 

** Differences in beliefs between men and women being kind (men minus women) **
gen OverallMen_Women = kindMenOverall - kindWomenOverall 
gen UniformMen_Women = kind3Men - kind3Women 
gen X2M1WMen_Women = kindMen2M1W - kindWomen2M1W 
gen X1M2WMen_Women = kindMen1M2W - kindWomen1M2W 

sum OverallMen_Women UniformMen_Women X2M1WMen_Women X1M2WMen_Women 

** Redo these summary stats but for only the Type Z subjects who have **
** no feedback or knowledge of what the Type C subjects in in the session **

sum OverallMen_Women UniformMen_Women X2M1WMen_Women X1M2WMen_Women if TypeZID==1 

** Nonparametric Wilcoxon tests for the (independent) type Z subjects - reported end of Section 4.3 **
signrank OverallMen_Women = 0 if TypeZID==1
signrank UniformMen_Women = 0 if TypeZID==1

** Table 5 regressions on belief differences (Men minus women) **
xtset sessnum
xtreg OverallMen_Women FemaleID TypeZID, re
outreg2 using beliefRegs.xls, replace ctitle(Overall) 10pct
xtreg UniformMen_Women FemaleID TypeZID, re
outreg2 using beliefRegs.xls, append ctitle(Uniform Gender) 10pct
xtreg X2M1WMen_Women FemaleID TypeZID, re
outreg2 using beliefRegs.xls, append ctitle(2 Men, 1 Woman) 10pct
xtreg X1M2WMen_Women FemaleID TypeZID, re
outreg2 using beliefRegs.xls, append ctitle(1 Man, 2 Women) 10pct

** Lets count frequency of women or men expected to be kinder, second paragraph of Section 4.3 **
gen OverallMKinder = 0 if OverallMen_Women == 0
replace OverallMKinder = 1 if OverallMen_Women > 0
replace OverallMKinder = -1 if OverallMen_Women < 0
gen UniformMKinder = 0 if UniformMen_Women == 0
replace UniformMKinder = 1 if UniformMen_Women > 0
replace UniformMKinder = -1 if UniformMen_Women < 0
gen X2M1WMKinder = 0 if X2M1WMen_Women == 0
replace X2M1WMKinder = 1 if X2M1WMen_Women > 0
replace X2M1WMKinder = -1 if X2M1WMen_Women < 0
gen X1M2WMKinder = 0 if X1M2WMen_Women == 0
replace X1M2WMKinder = 1 if X1M2WMen_Women > 0
replace X1M2WMKinder = -1 if X1M2WMen_Women < 0

table OverallMKinder TypeZID
table UniformMKinder TypeZID
table X2M1WMKinder TypeZID
table X1M2WMKinder TypeZID

clear
use beliefs_reorganized.dta
** Again, the mean belief frequencies for Figure 5 **
bysort numwomen: sum kindman
bysort numwomen: sum kindwoman

** Table 4 belief regressions depending on number of women in group **
xtset subsess
xtreg kindman numwomen femaleid typezid, re
outreg2 using bel_numWomen_Regs.xls, replace ctitle(Belief Men Kind) 10pct
xtreg kindwoman numwomen femaleid typezid, re
outreg2 using bel_numWomen_Regs.xls, append ctitle(Belief Women Kind) 10pct

